package com.hundsun.bible.facade.impl.account;

import java.util.Map;

import com.hundsun.bible.Page;
import com.hundsun.bible.PageUtil;
import com.hundsun.bible.domain.model.account.Account;
import com.hundsun.bible.facade.account.AccountManager;
import com.hundsun.bible.facade.account.FundListManager;

public class FundListManagerImpl implements FundListManager {
    private AccountManager accountManager;

    /**
     * 根据条件查看账户金额变动流水
     * @param searchMap
     * @param page
     * @return
     * @see com.hundsun.bible.facade.account.FundListManager#getAccountLogsByCondition(java.util.Map, com.hundsun.bible.Page)
     */
    public PageUtil<Map> getAccountLogsByUserId(Map<String, String> searchMap, Page page){
        long userId = Long.parseLong(searchMap.get("userId"));
        Account buyerAccount = accountManager.getBuyerAccount(userId);
        if(buyerAccount != null){
            searchMap.put("accountNo", buyerAccount.getAccountNo());
            return accountManager.getAccountLogsByUserId(searchMap, page);
        }
        return null;
    }

    /**
     * 商户账户资金变动表查询
     * @param searchMap
     * @param page
     * @return
     * @see com.hundsun.bible.facade.account.FundListManager#getMerchantAccountLogsByUserId(java.util.Map, com.hundsun.bible.Page)
     */
    public PageUtil<Map> getMerchantAccountLogsByUserId(Map<String, String> searchMap, Page page){
        long userId = Long.parseLong(searchMap.get("userId"));
        Account merchantAccount = null;
        if(searchMap.get("accountSubType").equals("01")){//收款帐户
            merchantAccount = accountManager.getSellerReceiveAccount(userId);
        }else if(searchMap.get("accountSubType").equals("02")){//付款帐户
            merchantAccount = accountManager.getSellerPayAccount(userId);
        }
        if(merchantAccount != null){
            searchMap.put("accountNo", merchantAccount.getAccountNo());
            return accountManager.getAccountLogsByUserId(searchMap, page);
        }
        return null;
    }

    public AccountManager getAccountManager() {
        return accountManager;
    }

    public void setAccountManager(AccountManager accountManager) {
        this.accountManager = accountManager;
    }



}
